package 
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	import flash.external.ExternalInterface;
	import flash.utils.setTimeout;
	
	/**
	 * ...
	 * @author Ning
	 */
	public class Main extends Sprite 
	{
		private var _player:VideoPlayer;
		public function Main():void 
		{
			if (stage) onAddToStage();
			else addEventListener(Event.ADDED_TO_STAGE, onAddToStage);
		}
		
		private function onAddToStage(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, onAddToStage);
			// entry point
			setTimeout(init, 200);
		}
		
		private function init():void
		{
			
			AppGlobal.STAGE = this.stage;
			AppGlobal.STAGE.scaleMode = StageScaleMode.NO_SCALE;
			AppGlobal.STAGE.align = StageAlign.TOP_LEFT;
			
			_player = new VideoPlayer();
			addChild(_player);
			
			if (ExternalInterface.available) {
				ExternalInterface.addCallback('setData', _player.setData);
				ExternalInterface.call('isReady');
			}
			
		//	_player.setData('http://www.bangbangtv.com/flv/woniu.flv');
		}
	}
}